#ifndef MYTHREAD_H
#define MYTHREAD_H

#define XG_CMD_CLEAR_ENROLL           0x11 //清除指定ID登录数据
#define XG_CMD_GET_EMPTY_ID           0x13 //获取空（无登录数据）ID
#define XG_CMD_ENROLL                 0x16 //指定ID登录
#define XG_CMD_VERIFY                 0x17 //1:1认证或1:N识别

/******************************状态代码****************************************/
#define XG_INPUT_FINGER               0x20 //请求放入手指
#define XG_RELEASE_FINGER             0x21 //请求拿开手指

/******************************错误代码****************************************/
#define	XG_ERR_SUCCESS                0x00 //操作成功
#define	XG_ERR_FAIL                   0x01 //操作失败
#define XG_ERR_COM                    0x02 //通讯错误
#define XG_ERR_DATA                   0x03 //数据校验错误
#define XG_ERR_INVALID_PWD            0x04 //密码错误
#define XG_ERR_INVALID_PARAM          0x05 //参数错误
#define XG_ERR_INVALID_ID             0x06 //ID错误
#define XG_ERR_EMPTY_ID               0x07 //指定ID为空（无登录数据）
#define XG_ERR_NOT_ENOUGH             0x08 //无足够登录空间
#define XG_ERR_NO_SAME_FINGER         0x09 //不是同一根手指
#define XG_ERR_DUPLICATION_ID         0x0A //有相同登录ID
#define XG_ERR_TIME_OUT               0x0B //等待手指输入超时
#define XG_ERR_VERIFY                 0x0C //认证失败
#define XG_ERR_NO_NULL_ID             0x0D //已无空ID
#define XG_ERR_BREAK_OFF              0x0E //操作中断
#define XG_ERR_NO_CONNECT             0x0F //未连接
#define XG_ERR_NO_SUPPORT             0x10 //不支持此操作
#define XG_ERR_NO_VEIN                0x11 //无静脉数据
#define XG_ERR_MEMORY                 0x12 //内存不足
#define XG_ERR_NO_DEV                 0x13 //设备不存在
#define XG_ERR_ADDRESS                0x14 //设备地址错误
#define XG_ERR_NO_FILE                0x15 //文件不存在
#define XG_ERR_VER                    0x16 //版本错误
#define XG_ERR_PACKET_PREFIX          0x30 //包头错误
#define XG_ERR_PACKET_CHECK           0x31 //校验和错误
#define XG_ERR_PACKET_LACK            0x32 // 数据不足

typedef long ( *SetFV_SetDebug)(long); //定义函数指针
typedef long ( *SetFV_ConnectDev)(char *,char *);
typedef long ( *SetFV_GetDevParam)(long,char *);
typedef long ( *SetFV_HexToAscii)(char *,long,char *);
typedef long ( *SetFV_VerifyUser)(char *,char *,long,char *,char *);
typedef long ( *SetFV_CreateVeinLib)(long);
typedef long ( *SetFV_ImportVeinTemp)(long,long,char *,char *);
typedef long ( *SetFV_GetNullID)(long);
typedef long ( *SetFV_SearchUser)(long,char *,long,char *);
typedef long ( *SetFV_ExportVeinTemp)(long,long,char *);
typedef long ( *SetFV_DestroyVeinLib)(long);
typedef long ( *SetFV_RecvCmdPacket)(long,char *,long);
typedef long ( *SetFV_AsciiToHex)(char *,char *);
typedef long ( *SetFV_SendCmdPacket)(long,long,char *);
typedef long ( *SetFV_WriteDevTemp)(long,long,char *,char *);
typedef long ( *SetFV_ReadDevTemp)(long,long,char *);
typedef long ( *SetFV_WriteDevUserInfo)(long,long,long,char *);
typedef long ( *SetFV_ReadDevUserInfo)(long,long,long,char *);
typedef long ( *SetFV_DeleteDevTemp)(long,long);

static SetFV_SetDebug FV_SetDebug;
static SetFV_ConnectDev FV_ConnectDev;
static SetFV_GetDevParam FV_GetDevParam;
static SetFV_HexToAscii FV_HexToAscii;
static SetFV_VerifyUser FV_VerifyUser;
static SetFV_CreateVeinLib FV_CreateVeinLib;
static SetFV_ImportVeinTemp FV_ImportVeinTemp;
static SetFV_GetNullID FV_GetNullID;
static SetFV_SearchUser FV_SearchUser;
static SetFV_ExportVeinTemp FV_ExportVeinTemp;
static SetFV_DestroyVeinLib FV_DestroyVeinLib;
static SetFV_RecvCmdPacket FV_RecvCmdPacket;
static SetFV_AsciiToHex FV_AsciiToHex;
static SetFV_SendCmdPacket FV_SendCmdPacket;
static SetFV_WriteDevTemp FV_WriteDevTemp;
static SetFV_ReadDevTemp FV_ReadDevTemp;
static SetFV_WriteDevUserInfo FV_WriteDevUserInfo;
static SetFV_ReadDevUserInfo FV_ReadDevUserInfo;
static SetFV_DeleteDevTemp FV_DeleteDevTemp;

static long DevHandle = 0;
static int MaxUser = 0;
static char sTemp[20*1024] = { 0 };
static char sChara[2*1024] = { 0 };

#include <QThread>
#include <QWidget>
#include <QLabel>
#include <authenticationpopups.h>

//class HintWindow;

class mythread : public QThread
{
    Q_OBJECT
public:
    explicit mythread(QWidget *parent = nullptr);
    //重写父类的run方法
    void run();
    //定义一个公有方法接收传递过来的参数--》父窗口指针
    void getWindowPointer(QWidget *parent1);
    //定义一个公有方法接收传递过来的参数--》功能编号
    void getWindowOpenBox(int ret);
    void getWindowOpenBox(int ret,int digital_vein_device_id);
    //通过id获取指静脉信息
    int getDigitalInformation(int UserId,char *sUserInfo);
    //通过id设置初始信息
    int getWriteDevInfo(int UserId,QString sUserInfo);
//    void setGainUid(QStringList list){uidList = list;}//获取所有用户UID
    void DeletingUsersOne(int id);//传入uid删除一个用户
    void DeletingUsersOne(QString FilePath);//传入文件路径删除一个用户
    int setUserOne(QString FilePath);//更新一个用户
    int verification1_1(int *pParam);//>0 1:1    =0 1:n
    int ifDevHandle();//判断指静脉设备是否连接成功
    int isUid(int uid);//判断uid是否被使用

signals:
    void sendThUserData(int,QString);   //用来传递在主界面数据的信号(1->显示提示信息)

private:
    int getNullId();//获取空id
    int DevAddUserProc(int *pParam);//采集指静脉信息

    QWidget *parent;//父窗口指针
    AuthenticationPopups *aps;//指纹弹窗指针
//    HintWindow *hintw;//指静脉提示信息窗口

    int openBox;//判断是否开箱动作(0->不是,1->是,2->采集信息)

private:
    int digital_vein_device_id_;//1:1验证用户id
//    QStringList uidList;//保存所有用户UID

};

#endif // MYTHREAD_H
